package com.ft.oa.web.presalesController;

import com.ft.oa.domain.clueproject.ClueProject;
import com.ft.oa.domain.clueproject.ClueProjectProgressAttachment;
import com.ft.oa.domain.clueproject.ThreadContact;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.domain.dto.condition.SysUserDTO;
import com.ft.oa.service.clueprojectService.ClueprojectprogressattachmentServer;
import com.ft.oa.service.clueprojectService.IClueProjectAreaServer;
import com.ft.oa.service.clueprojectService.IclueprojectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/clueproject")
public class ClueprojectController {

    @Autowired
    private IclueprojectService iclueprojectService;
    @Autowired
    private IClueProjectAreaServer iClueProjectAreaServer;
    @Autowired
    private ClueprojectprogressattachmentServer clueprojectprogressattachmentServer;
    /**
     * 新增售前文件
     */
    @PostMapping("/addpresalefile")
    private ApiResult addpresalefile(@RequestBody ClueProjectProgressAttachment clueProjectProgressAttachment){
        clueprojectprogressattachmentServer.addpresalefile(clueProjectProgressAttachment);
        return ApiResult.simpleSuccess(); 
    }
    /**
     * 查询项目售前文件
     */
    @GetMapping("/getpresalefile")
    private ApiResult getpresalefile(@RequestParam int id ){
        return ApiResult.successWithData(clueprojectprogressattachmentServer.getpresalefile(id));
    }
    /**
     * 修改附件状态
     */
    @PostMapping("/updateStats")
    private ApiResult updateStats(@RequestParam int id , int starts){
        clueprojectprogressattachmentServer.updateStats(id,starts);
        return ApiResult.simpleSuccess();
    }
    /**
     * 查询项目线索
     */
    @PostMapping("/getclueAll")
    public ApiResult getclueAll(){
        return ApiResult.successWithData(iclueprojectService.getclueAll());
    }
    /**
     * 查询项目线索主表 用于编辑
     * @return
     */
    @GetMapping("/getthread")
    public ApiResult getthread(@RequestParam Long threadId){
        return ApiResult.builder().code(200).msg("项目线索返回成功").data(iclueprojectService.getprojectthread(threadId)).build();
    }
    /**
     * 查询项目线索主表
     * @return
     */
    @GetMapping("/vallthread")
    public ApiResult vallthread(@RequestParam String clientname ,String importantLevel,String xsstatus,int page, int size){
        return ApiResult.builder().code(200).msg("项目线索返回成功").data(iclueprojectService.vallthread(clientname,importantLevel,xsstatus,page,size)).build();
    }
    /**
     * 新增项目线索
     * @return
     */
    @PostMapping("/getthread/addThread")
    public ApiResult addThread(@RequestBody ThreadContact threadContact){
        return iclueprojectService.addprojectthread(threadContact);
    }
    /**
     * 区域表 clue_project_area
     */
    @PostMapping("/area")
    public ApiResult arealist(){
        return ApiResult.builder().code(200).msg("区域列表返回成功").data(iClueProjectAreaServer.arealist()).build();
    }
    /**
     * 编辑项目线索
     */
    @PostMapping("/updateclue")
    public ApiResult updateclue(@RequestBody ThreadContact threadContact){
        return ApiResult.builder().code(200).msg("项目线索更新成功").data(iclueprojectService.updateclue(threadContact)).build();
    }

    /**
     * 删除项目线索
     * @param threadId
     * @return
     */
    @GetMapping("/dellteclue")
    public ApiResult dellteclue(@RequestParam Long threadId){
        return ApiResult.builder().code(200).msg("项目线索删除成功").data(iclueprojectService.dellteclue(threadId)).build();
    }
}
